package com.aaa.service.sys.impl;

import com.aaa.dao.sys.DeptDao;
import com.aaa.pojo.Dept;
import com.aaa.service.sys.DeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptDao deptDao;
    @Override
    public List<Dept> findAll(String page,String limit) {
        int parseInt = Integer.parseInt(page);
        int parseLimit = Integer.parseInt(limit);
        int start = (parseInt - 1)*parseLimit;
        List<Dept> all = deptDao.findAll(start,parseLimit);
        return all;
    }

    @Override
    public int findCount() {
        int count = deptDao.findCount();
        return count;
    }

    @Override
    public int insert(Dept dept) {
        int insert = deptDao.insert(dept);
        return insert;
    }

    @Override
    public int delete(List<String> idList) {
        int delete = deptDao.delete(idList);
        return delete;
    }

    @Override
    public int update(Dept dept) {
        int update = deptDao.update(dept);
        return update;
    }

    @Override
    public List<Dept> findIf(String deptName, String createBy, String updateBy, String page, String limit) {
        int parsePage = Integer.parseInt(page);
        int parseLimit = Integer.parseInt(limit);
        int start = (parsePage - 1)*parseLimit;

        List<Dept> anIf = deptDao.findIf(deptName, createBy, updateBy, start, parseLimit);
        return anIf;
    }

    @Override
    public int findIfCount(String deptName, String createBy, String updateBy, String page, String limit) {
        int parsePage = Integer.parseInt(page);
        int parseLimit = Integer.parseInt(limit);
        int start = (parsePage - 1)*parseLimit;

        int ifCount = deptDao.findIfCount(deptName, createBy, updateBy, start, parseLimit);
        return ifCount;
    }
}
